<template>
	<view style="padding: 20rpx;">
		<u-form-item style="border-bottom: 1rpx solid #EEEEEE;" :label-width="150" label="原密码:">
			<u-input type="password" :clearable='false' v-model="oldPassword" :border="true" placeholder="请输入原密码" />
		</u-form-item>
		<u-form-item style="border-bottom: 1rpx solid #EEEEEE;" :label-width="150" label="新密码:">
			<u-input type="password" :clearable='false' v-model="newPassword" :border="true" placeholder="请输入新密码" />
		</u-form-item>
		<view class="btnPas" @click="btnPassWord">修改密码</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
export default {
	data() {
		return {
			oldPassword: '',
			newPassword: ''
		};
	},
	methods: {
		btnPassWord() {
			if(this.oldPassword === ''){
				this.$refs.uToast.show({
					title: '请输入原密码',
				});
				return;
			}
			if(this.newPassword === ''){
				this.$refs.uToast.show({
					title: '请输入新密码',
				});
				return;
			}
			let data = {
				new_password: this.newPassword,
				password: this.oldPassword
			};
			this.$u.api.getmodifyPassword(data).then(res => {
				this.$refs.uToast.show({
					title: '密码修改成功',
					type: 'success'
				});
			}).catch(e =>{
				this.$refs.uToast.show({
					title: '密码修改失败',
					type: 'error'
				});
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.btnPas {
	width: 80%;
	padding: 20rpx;
	background: #05B2B5;
	color: #fff;
	font-size: 30rpx;
	margin: 0 auto;
	text-align: center;
	border-radius: 50rpx;
	margin-top: 50rpx;
}
</style>
